package com.easy.customer.service;

import com.easy.common.bean.CustomerContacts;
import com.easy.common.service.ICustomerContactsService;
import com.easy.customer.mapper.CustomerContactsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CustomerContactsService implements ICustomerContactsService {
    @Autowired
    CustomerContactsMapper customerContactsMapper;
    @Override
    public CustomerContacts insert(CustomerContacts contacts) {
        customerContactsMapper.insert(contacts);
        return customerContactsMapper.selectById(contacts.getId());
    }

    @Override
    public CustomerContacts update(CustomerContacts contacts) {
        customerContactsMapper.updateById(contacts);
        return customerContactsMapper.selectById(contacts.getId());
    }

    @Override
    public int delete(Integer id) {
        return customerContactsMapper.deleteById(id);
    }

    @Override
    public int setPrimary(Integer id) {
        customerContactsMapper.resetPrimaryFlags();
        return customerContactsMapper.setPrimary(id);
    }
}
